#include<iostream>
#include<cstdio> 
using namespace std;
int main()
{
	long long a,b,c,d,e,f,g,h,i;
	scanf("%lld:%lld:%lld",&a,&b,&c);
	scanf("%lld:%lld:%lld",&d,&e,&f);
	cin>>g;
	h=a*60*60+b*60+c;
	i=d*60*60+e*60+f;
	cout<<g*(i-h);
} 
